package com.onion.orm.plugin.spring;

import com.onion.orm.config.EnhancedConfig;
import io.github.lukehutch.fastclasspathscanner.FastClasspathScanner;
import io.github.lukehutch.fastclasspathscanner.scanner.ScanResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.annotation.RetentionPolicy;
import java.util.List;

public class EnhancedScanner {

    private Logger logger = LoggerFactory.getLogger(EnhancedScanner.class);

    private EnhancedConfig config;

    public EnhancedScanner(EnhancedConfig config){
        this.config = config;
    }

    public ScanResult doScan(){
        List<String> listPath = config.getScanPath();
        return new FastClasspathScanner(listPath.toArray(new String[]{}))
                .ignoreFieldVisibility().enableFieldAnnotationIndexing()
                .setAnnotationVisibility(RetentionPolicy.RUNTIME)
                .scan();
    }

}